home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7320 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  58 lines

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Function Prototype placement in source files
  5. Date: 16 Feb 1996 15:55:41 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb16085541@qcd.lanl.gov>
  8. References: <4g0obg$78b@barad-dur.nas.com>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: gldnspud@kali.nas.com's message of Fri, 16 Feb 1996 01:58:30 GMT
  13.  
  14. In article <4g0obg$78b@barad-dur.nas.com> gldnspud@kali.nas.com (Matt
  15. Scott) writes: 
  16. <snip>
  17.    main()
  18.      {
  19.        float x;
  20.        float one(void);                /* 1 */
  21.        void two(void);                 /* 2 */
  22. <snip>
  23.    My question is this: is there a compelling reason not to prototype
  24.    functions above all of the functions using it, such as:
  25.  
  26. On the contrary.
  27.  
  28. <snip>
  29.    In almost every instance of prototypes I've seen, they are declared
  30.    outside of any function -- mostly above all other functions, and in
  31.    a header file most often.
  32.  
  33. The greatest advantage fo putting it in a header file is that you can
  34. make sure that _exactly_ the same declaration is included at function
  35. definition time and function use time. So, if the definition doesn't
  36. match use, it shall be reported.
  37.  
  38.    Is there a good reason to do it the way he and the book do it?
  39.  
  40. Can't think of any. Probably the mentality of thinking of a function
  41. as a unit, rather than an entire compilation unit at a time. I think
  42. that is a mistake: it is good practice to use compilation units in the
  43. same way as modules of other languages, or even smaller units. 
  44.  
  45.    Thanks in advance for any thoughtful answers.
  46.  
  47. Sorry, couldn;t find any useful thoughts.
  48.  
  49. Cheers
  50. Tanmoy
  51. --
  52. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  53. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  54. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  55. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  56. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  57. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  58.